package io.github.consoles;

import org.junit.Test;

import java.util.Arrays;
import java.util.List;
import java.util.Optional;

/**
 * Created by yiihua-013 on 16/10/24.
 */
public class Sample {
    @Test
    public void test() {
        final List<Integer> numbers = Arrays.asList(1, 2, 3, 4);
        final Optional<Integer> sum = numbers.stream()
                .reduce((a, b) -> a + b);
        sum.orElseGet(() -> 0);
        System.out.println(sum.get());
    }
}
